#include <cmath>
#include <iomanip>
#include <iostream>

#define PI 3.14159
using namespace std;

struct node {
    double x, y, z;

    node(double x_, double y_, double z_) : x(x_), y(y_), z(z_) {}
};

struct circle {
    node heart;
    double radius;

    circle(node heart_, double radius_) : heart(heart_), radius(radius_) {}
};

// 计算两点间距离的函数
double Calculate_distance(node A, node B) {
    return sqrt(pow(A.x - B.x, 2.0) + pow(A.y - B.y, 2.0) + pow(A.z - B.z, 2.0));
}

int main() {
    // 输入A点、B点、C点的坐标和装置半径
    double Ax, Ay, Az;
    double Bx, By, Bz;
    double Cx, Cy, Cz;
    double R;
    cin >> Ax >> Ay >> Az;
    cin >> Bx >> By >> Bz;
    cin >> Cx >> Cy >> Cz;
    cin >> R;
    // 创建点对象
    node A(Ax, Ay, Az);
    node B(Bx, By, Bz);
    node C(Cx, Cy, Cz);
    // 计算A点到C点，B点到C点，和A点到B点的距离
    double d_AC = Calculate_distance(A, C);
    double d_BC = Calculate_distance(B, C);
    double d_AB = Calculate_distance(A, B);
    double cos_ACB = (d_AC * d_AC + d_BC * d_BC - d_AB * d_AB) / (2 * d_AC * d_BC);
    // 计算角度并绕行路径
    double cos_ACM = R / d_AC;
    double cos_BCN = R / d_BC;
    double d_AM = sqrt(d_AC * d_AC - R * R);
    double d_BN = sqrt(d_BC * d_BC - R * R);
    double d_circle = (acos(cos_ACB) - acos(cos_ACM) - acos(cos_BCN)) * R;
    // 输出最短距离
    cout << fixed << setprecision(2) << d_AM + d_BN + d_circle << endl;
    return 0;
}